# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
  def link_agregar_campos(name,f,association)
    new_object = f.object.class.reflect_on_association(association).klass.new

    fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder|
           render(association.to_s.singularize + "_fields", :f => builder)  
    end
    puts association.to_s.singularize + "_fields", f
    link_to_function(name,h("agregar_campos(this,\"#{association}\",\"#{escape_javascript(fields)}\")"))
   
  end
end

